package reflex;

/**
 * @author ChenYongHao
 * @date 2023/5/4 11:31
 * @desc 反射
 */
class Student {
    private String name;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}

public class Reflex_Demo {
    public static void main(String[] args) throws ClassNotFoundException {
        // 方法1：使用类的class属性来获取该类对应的Class对象
        Class<Student> c1 = Student.class;
        System.out.println(c1);
        // 方法2：调用对象的getClass()方法，返回该对象所属类对应的Class对象
        Class<? extends Student> c2 = new Student().getClass();
        System.out.println(c2);
        // 方法3：使用Class类中的静态方法forName(String className)
        Class<?> c3 = Class.forName("Student");
        System.out.println(c3);
    }
}
